#!/bin/bash

# 启用错误检查，遇到错误时停止执行
set -e

# 设置工作空间路径
WORKSPACE=~/dingtek_mower

# 进入工作空间目录
cd $WORKSPACE

# 定义需要构建的包列表
PACKAGES_C=(
    ackermann_msgs
    serial
    tf2_tools
    mower_msgs
    hardware_interface
    imu_ahrs
    lslidar_msgs
    lslidar_driver
)

PACKAGES_Python=(
    mower_description
    dynamic_controller
    global_plan_path
    robot_localization_node
    gps_driver
    border_map
    panel
    robot_bringup
)

# 循环构建所有包
for package in "${PACKAGES_C[@]}"; do
  echo "Building $package..."
  colcon build --packages-select $package 
done

for package in "${PACKAGES_Python[@]}"; do
  echo "Building $package..."
  colcon build --packages-select $package --symlink-install
done

# 设置环境变量
source $WORKSPACE/install/setup.bash

echo "Build completed and environment set!"
